#pragma once;
#include <iostream>
using namespace std;
class Matrix
{
	int d1, d2, matrix[100][100];
public:
	Matrix(){}
	//Matrix(int,int,int tempmatrix[][100]);
	void Matrix_Input();
	void Matrix_Show();
	void Matrix_Multiply();
	void Matrix_Transpose();
	void Matrix_Rotate();
};

void Matrix::Matrix_Input()
{
	int i, j;
	cout << "Please input the two dimensions of the matrix: ";
	cin >> d1 >> d2;
	cout << "Please input the elements of the matrix: ";
	for (i = 0; i < d2; i++)
	{
		for (j = 0; j < d1; j++)
		{
			cin >> matrix[i][j];
		}
	}
}

void Matrix::Matrix_Show()
{
	for (int i = 0; i<d2; i++)
	{
		for (int j = 0; j < d1; j++)
		{
			cout << matrix[i][j]<<"   ";
		}
		cout << endl;
	}
}

void Matrix::Matrix_Multiply()
{
	cout << endl << "Do you want to multiply the matrix with a number(Y/N)? ";
	char flag;
	cin >> flag;
	while (tolower(flag) == 'y')
	{
		cout << "Please input the number will multiply the matrix: ";
		int number;
		cin >> number;
		for (int i = 0; i < d2; i++)
		{
			for (int j = 0; j < d1; j++)
			{
				matrix[i][j] *= number;
			}
		}
		cout << "The matrix multiplied by the number is:" << endl;
		Matrix_Show();
		cout << "Do you want to continue to multiply the matrix(Y/N)? ";
		cin >> flag;
	}
}

void Matrix::Matrix_Transpose()
{
	cout << endl << "Do you want to transpose the matrix(Y/N)? ";
	char flag;
	cin >> flag;
	if (tolower(flag) == 'y')
	{
		cout << "The transposed matrix is:" << endl;
		for (int j = 0; j < d1; j++)
		{
			for (int i = 0; i < d2; i++)
			{
				cout << matrix[i][j] << "  ";
			}
			cout << endl;
		}
	}
}

void Matrix::Matrix_Rotate()
{
	cout << endl << "Do you want to rotate the matrix(Y/N)? ";
	char flag;
	cin >> flag;
	while (tolower(flag) == 'y')
	{
		cout << "Please input the angle of rotation(90/180/270): ";
		int i, j, angle;
		cin >> angle;
		switch (angle)
		{
		case 90:
			cout << "The matrix after rotating 90 is:" << endl;
			for (j = 0; j < d1; j++)
			{
				for (i = d2 - 1; i >= 0; i--)
				{
					cout << matrix[i][j] << "  ";
				}
				cout << endl;
			}
			break;
		case 180:
			cout << "The matrix after rotating 180 is:" << endl;
			for (i = d2 - 1; i >= 0; i--)
			{
				for (j = d1 - 1; j >= 0; j--)
				{
					cout << matrix[i][j] << "  ";
				}
				cout << endl;
			}
			break;
		case 270:
			cout << "The matrix after rotating 270 is:" << endl;
			for (j = d1 - 1; j >= 0; j--)
			{
				for (i = 0; i < d2; i++)
				{
					cout << matrix[i][j] << "  ";
				}
				cout << endl;
			}
			break;
		}
		cout << "Do you want to continue to rotate the matrix(Y/N)? ";
		cin >> flag;
	}
}

void main()
{
	Matrix m;
	m.Matrix_Input();
	cout << "The original matrix you inputted is:" << endl;
	m.Matrix_Show();
	m.Matrix_Multiply();
	m.Matrix_Transpose();
	m.Matrix_Rotate();
}